package com.sleep.drug_traceability.controller;

import com.sleep.drug_traceability.service.SubmitService;
import com.sleep.drug_traceability.vo.*;
import com.sleep.drug_traceability.vo.params.ConDrugParam;
import com.sleep.drug_traceability.vo.params.ManDrugParam;
import com.sleep.drug_traceability.vo.params.SelDrugParam;
import com.sleep.drug_traceability.vo.params.TraDrugParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Sleep-6000
 * @date 2022/4/27
 */
@RestController
@RequestMapping("submit")
public class SubmitController {

    @Autowired
    private SubmitService submitService;

    /**
     * 药品生产商的药品生产数据的页面，提交药品生产数据
     * @param manDrugParam 药品生产数据
     * @param token token
     * @return Result
     */
    @PostMapping("mand")
    public Result submitManDrug(@RequestBody ManDrugParam manDrugParam, @RequestHeader("Authorization") String token) {
        return submitService.submitManDrug(manDrugParam, token);
    }

    /**
     * 药品生产商的药品运输数据的页面，提交药品运输数据
     * @param traDrugParam 药品运输数据
     * @param token token
     * @return Result
     */
    @PostMapping("trad")
    public Result submitTraDrug(@RequestBody TraDrugParam traDrugParam, @RequestHeader("Authorization") String token) {
        return submitService.submitTraDrug(traDrugParam, token);
    }

    /**
     * 销售商的药品购买数据的页面，提交药品购买数据
     * @param selDrugParam 药品购买数据
     * @param token token
     * @return Result
     */
    @PostMapping("seld")
    public Result submitSelDrug(@RequestBody SelDrugParam selDrugParam, @RequestHeader("Authorization") String token) {
        return submitService.submitSelDrug(selDrugParam, token);
    }

    /**
     * 销售商的消费者数据的页面，提交消费者数据
     * @param conDrugParam 消费者数据
     * @param token token
     * @return Result
     */
    @PostMapping("cond")
    public Result submitConDrug(@RequestBody ConDrugParam conDrugParam, @RequestHeader("Authorization") String token) {
        return submitService.submitConDrug(conDrugParam, token);
    }
}
